package com.jiajia.study.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zjiajia
 * @date 2024/7/16 9:37
 */

@RestController
public class HelloController {

    @GetMapping("index")
    public String index(){
        return "index";
    }

    @PostMapping("index")
    public String indexPost( ){
        return "index";
    }

    @GetMapping("userInfo")
    public String userInfo() throws JsonProcessingException {
        Map<String,Object> data = new HashMap<>();
        data.put("username","测试");
        data.put("passwd","root");
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.writeValueAsString(data);
    }
}
